package com.xiaxinyu.thread.pool.commom;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ThreadPoolExecutor;

/**
 * @author XIAXINYU3
 * @date 2021/6/11
 */
@Slf4j
public class Task implements Runnable {
    private int index;
    private ThreadPoolExecutor executor;

    public Task(int index, ThreadPoolExecutor executor) {
        this.index = index;
        this.executor = executor;
    }

    @Override
    public void run() {
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        log.info("production ... ,poolSize={}, activeThreads={}, queuedTasks={}, index={}",
                executor.getPoolSize(), executor.getActiveCount(), executor.getQueue().size(), index);
    }
}
